﻿Shader "Hidden/BushingFlowMap"
{
    Properties
    {
        _MainTex ("_MainTex", 2D) = "white" {}
		//_BrushIndexInMainTex("_BrushIndexInMainTex",Int) = 0
		//_OperaingTex ("_OperaingTex", 2D) = "white" {}
		//_BrushIndexInOperaTex("_BrushIndexInOperaTex",Int) = 0
		_BrushTex ("_BrushTex", 2D) = "white" {}
		_BrushStrong("_BrushStrong",range(0,5)) = 1
		_BrushMaxStrong("_BrushMaxStrong",range(0,1)) = 1
		

    }
    SubShader
    {
        // No culling or depth
        Cull Off ZWrite Off ZTest Always

        Pass
        {
            CGPROGRAM

			#pragma multi_compile _CHANNEL_UV0 _CHANNEL_UV1 _CHANNEL_UV2
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
				#if _CHANNEL_UV1
					float2 uv : TEXCOORD2;
				#elif  _CHANNEL_UV2
					float2 uv : TEXCOORD1;
				#else
					float2 uv : TEXCOORD0;
				#endif
                
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                float4 vertex : SV_POSITION;
            };

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = v.uv;
                return o;
            }

            sampler2D _MainTex;
			sampler2D _OperaingTex;
			sampler2D _BrushTex;
			//float _BrushIndexInMainTex;
			//float _BrushIndexInOperaTex;
			float _BrushStrong;
			float _BrushMaxStrong;
	 
             
			float4 _GlobalBrushDir;

			float4 frag (v2f i) : SV_Target
            {
                float4 col = tex2D(_MainTex, i.uv);
				 
				float2 uvb = float2(i.uv.x,1-i.uv.y);
				float4 brush = tex2D(_BrushTex, uvb);
			
				float addValue = brush.r ;
			 
#if _CHANNEL_UV1
				float4 flowMap = float4(_GlobalBrushDir.xy,0,1);
			 
#else
				float4 flowMap = float4(_GlobalBrushDir.zw,0,1);
	 ;
#endif
			 if (addValue == 0)
				 return col;
		 
	 
				//return flowMap;
				col.rg = lerp(col.rg, flowMap.rg, saturate( addValue*_BrushStrong));
				col.b = 0.5;
				col.a = 1;
                return col;
            }

			 
            ENDCG
        }




    }
}
